// 购物车

export default {
  state: {
    info: 'hello'
  },
  mutations: {
    // 定义mutation，用于修改状态
    updateInfo(state, payload) {
      state.info = payload
    }
  },
  actions: {
    // 2秒后更新状态
    updateInfo(context, payload) {
      setTimeout(() => {
        context.commit('updateInfo', payload)
      }, 2000)
    }
  },
  getters: {
    // 定义一个getters
    formatInfo(state) {
      return state.info + 'Tom'
    }
  }
}
